package com.yequan.work;

import java.util.Objects;

/**
 * @author yequan
 * @date 2021/03/11 15:09
 **/
public class SwitchDemo {

    public static Integer maxStatus = 20;
    public static Integer otherMaxStatus = 20;


    public static void main(String[] args) {
//        if (!checkVersionNew("8.10.49", "8.10.50")) {
//            System.out.println("老版本");
//        }
//
//        setSubTitle();

//        t(6);
        r(6);
    }

    public static void r(int a) {
        ReplyMap newSafetySwitch = new ReplyMap();
        newSafetySwitch.put("voice_switch", 1);
        newSafetySwitch.success();

        ReplyMap oldSafeSwitch = new ReplyMap();
        oldSafeSwitch.put("voice_switch", 1);
        oldSafeSwitch.success();

        Object newVoiceSwitchObj = newSafetySwitch.get("voice_switch");
        Object oldVoiceSwitchObj = oldSafeSwitch.get("voice_switch");
        if (Objects.nonNull(newVoiceSwitchObj) && Objects.nonNull(oldVoiceSwitchObj)) {
            String newVoiceSwitchStr = String.valueOf(newVoiceSwitchObj);
            String oldVoiceSwitchStr = String.valueOf(oldVoiceSwitchObj);
            if (!newVoiceSwitchStr.equals(oldVoiceSwitchStr)) {
                System.out.println("newVoiceSwitch is different from oldVoiceSwitch! user_cid:{} newVoiceSwitchStr:{}, oldVoiceSwitchStr:{}");
            }
        }
    }

    public static void t(int a) {
        switch (a) {
            case 1:
                System.out.println("1");
                break;
            case 2:
                System.out.println("2");
                break;

            default:
                System.out.println("default");
                break;
        }
    }


    public static void setSubTitle() {
        String subTitle = null;
        switch (maxStatus) {
            case 80:
                try {
                    if (null == otherMaxStatus) {

                    } else if (80 == otherMaxStatus) {
                        subTitle = "完单了";
                    } else {
                        subTitle = "置空了";
                    }
                } catch (Exception e) {
                    subTitle = "置空了";
                }
                break;
            default:
                subTitle = "default置空了";
                break;
        }
        System.out.println(subTitle);
    }

    public static boolean checkVersionNew(String current_version, String target_version) {
        if (current_version == null) {
            return false;
        }
        String[] cv = current_version.split("\\.");
        String[] tv = target_version.split("\\.");
        boolean result = true;
        int loop = Math.min(cv.length, tv.length);
        for (int i = 0; i < loop; i++) {
            int c = Integer.parseInt(cv[i]);
            int t = Integer.parseInt(tv[i]);
            if (c > t) {
                break;
            }
            if (c < t) {
                result = false;
                break;
            }
            //未分出大小 比长度
            if (i == loop - 1 && cv.length < tv.length) {
                result = false;
                break;
            }
        }
        return result;
    }


}
